package com.tzbank.esbService.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;

public class GeneralSeqNo {
	
/***
 * 109010 AIP 台州银行ESB项目_标准服务_AIP人工智能平台 +智脑后管 
 * 	
 *  @author wangdajun&llz
 */
	private static final int minSeqId = 1;
	private static final int maxSeqId = 999999;
	private static AtomicRangeInteger atomicRangeInteger = new AtomicRangeInteger(minSeqId, maxSeqId);
	public static String generalGlobalSeqNo(String consumer) {	
		consumer = "109010";		
		String str = new SimpleDateFormat("yyMMddHHmmss").format(new Date());
		return consumer+str+GeneralSeqNo.getSequenceId();
	
	}
	//同一秒内生成唯一的6位序列号  109010
	private  static synchronized String getSequenceId() {
		Integer seqId = atomicRangeInteger.incrAndGet();
		if(null == seqId) {
			atomicRangeInteger = new AtomicRangeInteger(minSeqId, maxSeqId);
			seqId = 0;
		}
		String returnStr = String.format("%06d",seqId);
		return returnStr;
	}
	
/*	public static void main(String[] args) {
		//System.out.println(generalGlobalSeqNo("FRS"));
		//ESB180614150350000002
	}*/
	
}
